


function setStatus(id, status){
	var i = $('#' + id);
	if(status == 'disabled'){
		i.attr(status, status);
	}else{
		i.removeAttr("disabled");
	}
}

function disable(){
	setStatus("id_serialnumber", "disabled");
	setStatus("id_name", "disabled");
	setStatus("id_psn", "disabled");
}

function enable(){
	setStatus("id_serialnumber", "enable");
	setStatus("id_name", "enable");
	setStatus("id_psn", "enable");
}

function addButton(){
	var newButton = $('<img class="editButton" src="/static/img/page-edit-32x32.png" alt="" />');
	$(".deletelink").after(newButton);
}

function bindForm(){
	var form = $("input[@type=submit]");
	form.bind("click", function(e){
		enable();
		return true;	
	});
	
}

$(document).ready(
	function() {
		var d = $(".deletelink");
		if(d.length != 0){
			addButton();
			disable();
			
			bindForm();	
		
			$('.editButton').click(function() {
				enable();
			});
		}

	}
);

